template>
	<view>即将跳转登录页</view>
</template>

<script>
	import {mapState,mapMutations} from 'vuex'
	export default{
		data(){
			return{
				
			}
		},
		computed:{
			...mapState(['hasLogin']),  //对全局变量hasLogin进行监控
			
		},
		methods:{
			...mapMutations(['login']),  //对全局方法 login 进行监控
			toUser(data){
				window.location.href = 'http://wx.hidaoyou.com/wxwap/login';	
			},
			goBack(){
				uni.reLaunch({
					url: '../user/index/index'
				})
			}
		},
		onLoad(e) {
			var code = e.code;
			var token = e.token;
			var msg = e.msg;
			if(code == 1 || code == 0){
				if(code == 1){
					var data = {'token':token};
					this.login(data);
					this.$myRequest({
						method:'POST',
						url:'/api/user/info',
					}).then(res=>{
						console.log(res);
						if(res.data.code == 1){
							var data = res.data.data;
							data.token = token;
							//data.token = '79a73930b729502a2115ed266c408a3e061e944cd690eb3f8e45ffd37c6fde11'; //游客token
							// data.token = '65600c0f4388a5681949c6ff58e598cbae4760b069d27d812e8c65cd44b86ebc'; //导游token
							// data.token = 'bc5eef7187a1cf63821bd5e1a6de3995b221f8b9d8d7474972a9715cec2dd9fk'; //商家token
							this.login(data);
							this.goBack();
						}
					});
				}else{
					uni.showModal({
					  title: '登录结果',  
					  content: msg,
					  confirmText:'再次登录',
					  showCancel:false,
					  success: (res) => {  
						if (res.confirm) { 
							this.toUser();
						} 
					  }  
					})
				}
			}else{
				this.toUser();
			}	
		}
	}
</script>

<style>
</style>